<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="" content="">
  <title></title>
  <style></style>
</head>

<body>
  <p>ok</p>

  <script>

    let a
    for(let i = 1; i <= 10; i++){
      const a = document.createElement('a')
      a.innerHTML = i + '<br>'
      a.addEventListener('click', function(b){
        b.preventDefault()
        alert(i)
      })
      document.body.appendChild(a)
    }
  </script>
</body>

</html>